new Vue({
  el: '#app',
  data() {
    return {
      form: {
        Data: "article_unit",
        page: 1,			//页数
        limit: 10			//每页数据条数
      },
      formData: {},
      tableData: [{}],		//表格数据
      total: 1,
      dialogForm: false,
      title: '',
      multipleSelection: []
    }
  },
  mounted() {
    this.getList(this.form)
  },
  methods: {
    onSerach() {				//查询方法
      console.log("搜搜")
    },
    addContract() {
      console.log("跳转")
    },
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form)
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form)
    },
    getList(data) {     //换页方法
      let _this = this
      $.ajax({
        type: 'POST',
        url: DomainName + '/getTableInquiryAction?token='+$.cookie("token"),
        data,
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        success: function (Result) {
          if (Result.Status=='success') {
            _this.tableData = Result.tableData 
            _this.total = parseInt(Result.limit)
          }
        },
        dataType: "json"
      });
    },
    addEnterprise() {
      window.location.href = './Add.html'
    },
    editMember(Article_Unit_SerialNumber) {
      console.log(Article_Unit_SerialNumber);
      sessionStorage.setItem("Article_Unit_SerialNumber", Article_Unit_SerialNumber)
      window.location.href = './Edit.html?Article_Unit_SerialNumber=' + Article_Unit_SerialNumber
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    deletMember(row) {
      const _this = this;
      this.$confirm('此操作将删除该商品单位, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        row.Row_Status = '1'
        let data = { Data: JSON.stringify({ Modify: { article_unit: [row] } }) };
        $.ajax({
          url: DomainName + '/getEditAction?token=' + $.cookie('token'),
          type: 'POST',
          data,
          error: function () {
            _this.$message.error("删除失败，请稍后再试")
          },
          complete: function (XMLHttpRequest) {
            _this.loading = false
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          },
          success:function (res) {
            if (res.Status == 'success') {
              _this.$message({
                type: 'success',
                message: '删除成功!'
              });
              _this.getList(_this.form)
            }
          }
        })
      }).catch(() => {
        this.$message({
          type: 'warning',
          message: '已取消删除'
        });
      });
    },
  },
})